POV-Ray : Newsgroups : povray.newusers : "difference" with a composed object : "difference" with a composed object Server Time
6 Oct 2024 02:48:07 EDT (-0400)
  "difference" with a composed object  
From: McMinty
Date: 18 Jul 2009 14:30:01
Message: <web.4a621451d328db22dc80fc610@news.povray.org>
Hi,

I want to have a thin box (or plate) with a lot of equaly spaced holes inside.

Basically I know how to do it and it already worked, but I needed ~17min to
render the picture, so I hope there is a better (faster) way to reach my goal.


Here is what I did:

----------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"

#declare i=0; //just two counters
#declare j=0;


//here follows the box:
#declare pure_table=box{<0,0,0>, <-362, 1, 150>
 texture{
  pigment{color rgb<0.7,0.7,0.7>}
  normal{wrinkles scale 0.02}
  finish{phong 1.0 phong_size 120 metallic reflection 0.3 brilliance 2}
  }
 };

//one Hole is defined here:
#declare hole=sphere{<0,0.5,0>,0.7 pigment{color Black}};

//just a few constants
#declare hole_xoffset=4.75;
#declare hole_zoffset=3.75;
#declare holes_x=141;
#declare holes_z=57;


//this is the macro that gives me all the holes I want to have;
#macro all_holes()
union{#while(i< holes_x)
  #while(j<holes_z)
      object{hole translate <-hole_xoffset-i*2.5,0,hole_zoffset+j*2.5>}
 #declare j = j + 1;
      #end
  #declare j=0;
  #declare i =i + 1;
#end}
#end

//here I draw the difference between the table and the holes:
difference{object{pure_table}
object{all_holes()}}


//top-view camea
camera {
    location <-180, 90, 75>
    look_at <-160, 0, 70>
}


light_source {
    <-300, 90, 75>
    color White
}


/*this light source is just the test for me to see, if the holes are really
through the table*/
light_source {
  <-300,-70,75>
  color Blue
  }

plane{<0,1,0>,-100
      pigment{
    gradient x
    color_map{
        [0.8 rgb<0.9,0.9,0.9>  ]
        [1.0 rgb<0.5,0.5,0.5>  ]
              }
   turbulence 1
   }
}

---------------------------------------------------------------


Another thing I tried was not to have the macro but a normal definition

---------------
#declare all_holes=#while ...... #end
-------------

My Problem with this solution was, that I alway got error messages from the
POVRay-Parser when I ended the line with a ";"
But without the ";" all the spheres were actually drawn which is the complete
opposite from the thing I want to have.
Only the rendering time was very short....


Every advice or comment is appreciated.

Thanks


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.